#include <bits/stdc++.h>
using namespace std;

int arr[505][505], n, m, ans = 0;
int dir[4][2] = {{0,  1},
                 {0,  -1},
                 {1,  0},
                 {-1, 0}};

void func(int x, int y) {
    for (auto &k: dir) {
        int dx = x, dy = y;
        while (dx >= 1 and dx <= n and dy >= 1 and dy <= m) {
            dx += k[0];
            dy += k[1];
            if (arr[dx][dy]) {
                ++ans;
                break;
            }
        }
    }
}

int main() {
    cin >> n >> m;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            cin >> arr[i][j];

    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            if (arr[i][j] == 0)
                func(i, j);

    cout << ans << endl;
    return 0;
}